#pragma once

#include "genericproperty.h"
#include "vrdatacore_global.h"
#include <QStringList>

namespace VrDataCore
{
	template <typename T>
	class VRDATACORE_EXPORT StringProperty : public GenericProperty<T,QString>
	{
	public:
		typedef GenericProperty<T,QString> BaseClass;
		typedef BaseClass::SetFun QStringPropertySetFun;
		typedef BaseClass::GetFun QStringPropertyGetFun;
		StringProperty(const QString& datatype,const QString& name, const std::string& label,
			T* obj,QStringPropertySetFun set, QStringPropertyGetFun get,
			const QString& isshowgui,const QString& bindingguitype):
			BaseClass(datatype,name,label,obj,set,get,isshowgui,bindingguitype)
		{}

		void setValue(QString str)
		{
			GenericProperty<T,QString>::setValue(str);
		}

		virtual bool fromString(const QString& value)
		{
			setValue(value);
			return true;
		}
		virtual const QString toQString() const
		{
			return GenericProperty<T,QString>::getValue();
		}
	protected:
		virtual ~StringProperty() { }
	};
	//-------------------------------------------------------------------------------------------------------------------
	template <typename T>
	class VRDATACORE_EXPORT StringListProperty : public GenericProperty<T,QStringList>
	{
	public:
		typedef GenericProperty<T,QStringList> BaseClass;
		typedef BaseClass::SetFun QStringListPropertySetFun;
		typedef BaseClass::GetFun QStringListPropertyGetFun;
		StringListProperty(const QString& datatype,const QString& name, const std::string& label,
			T* obj,QStringListPropertySetFun set, QStringListPropertyGetFun get,
			const QString& isshowgui,const QString& bindingguitype):
			BaseClass(datatype,name,label,obj,set,get,isshowgui,bindingguitype)
		{}

		void setValue(const QStringList& strvec)
		{
			GenericProperty<T,QStringList>::setValue(strvec);
		}

		virtual bool fromString(const QString& value)
		{
			QStringList list = value.split(",",QString::SkipEmptyParts);
			setValue(list);
			return true;
		}
		virtual const QString toQString() const
		{
			QStringList list = GenericProperty<T,QStringList>::getValue();
			QString returnstring = "";
			for(int i=0;i<list.size();++i)
			{
				returnstring = returnstring +","+list.at(i);
			}
			return returnstring;
		}
	protected:
		virtual ~StringListProperty() { }
	};
}